<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class InfoCategory extends CI_Controller {
	
	public function index(){
		$this->load->model('Info');
		$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
		$GroupList=$this->Info->getCategoryList();
		$this->cismarty->assign('GroupList',$GroupList);
		$this->cismarty->display('info/infoCategory.tpl');
	}

	public function create(){
		$this->load->model('Info');
		$arr=array('title'=>$_POST['title']);
		$this->Info->createCategory($arr);
		self::index();
	}
	
	public function createInit(){
			$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
			$this->cismarty->display('info/insertCateGory.tpl');
	}

	public function delete(){
		$this->load->model('Info');
		$id=$_GET['id'];
		$GroupList=$this->Info->deleteCategoryInfoById($id);
		self::index();
	}
	
	public function update(){
			$this->load->model('Info');
			$arr=array('title'=>$_POST['title']);
			$id=$_POST['id'];
			$this->Info->updateCategoryInfo($id,$arr);
			self::index();
	}
	
	public function updateInit(){
			$this->load->model('Info');
			$newTitle=$this->Info->getCategoryInfoById($_GET['id']);
			$this->cismarty->assign('newTitle',$newTitle);

			$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
			$this->cismarty->display('info/updateCateGory.tpl');
	}
}